import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { RunePreviewCellRenderer } from "./cell/RunePreviewCellRenderer";
import { ItemData } from "../../../resource/info/ItemData";
import { ItemConfig } from "../../../resource/ItemConfig";
import { ItemInfo } from "../../../resource/info/ItemInfo";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
//class RunePreviewWindow
    
    export  class RunePreviewWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._itemDataArray = [];
            setSize(555, 226);
            titleHeight = 26;
            title = Language.getString(44056);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 38, 519, 175, this);
            this._tileList = ObjCreate.createTileList(30, 50, 504, 142, this);
            this._tileList.columnWidth = 126;
            this._tileList.rowHeight = 142;
            this._tileList.setStyle("cellRenderer", RunePreviewCellRenderer);
            return;
        }

        public set relatedItemData(arg1: ItemData)
        {
            this._relateItemData = arg1;
            this._itemDataArray.length = 0;
            var loc1=ItemConfig.instance.getItemsByJudge(this.isSameItemData);
            var loc2=0;
            while (loc2 < loc1.length) 
            {
                this._itemDataArray.push(new ItemData((loc1[loc2] as ItemInfo).item.code));
                ++loc2;
            }
            this.updateView();
            return;
        }

        /* internal  */isSameItemData(arg1: ItemInfo): Boolean
        {
            if (arg1.item.category == this._relateItemData.category && arg1.item.type == this._relateItemData.type && arg1.item.effect == this._relateItemData.effect && arg1.item.effectEx == this._relateItemData.itemInfo.item.effectEx && arg1.item.bind == 1) 
            {
                return true;
            }
            return false;
        }

        /* internal  */updateView(): void
        {
            this._tileList.dataProvider = new DataProvider(this._itemDataArray);
            return;
        }

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_relateItemData: ItemData;

        /* internal */ /* var */_itemDataArray: Array<any>;
    }
